﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Presentation.Web.MVC.Client.Controllers;
using Infraestructure.CrossCutting.Caching;
using Infraestructure.CrossCutting.IoC;
using Domain.MainModule.Entities;

namespace Presentation.Web.MVC.Client.ViewUserControl
{
    public class BankAccountViewUserControl : System.Web.Mvc.ViewUserControl<BankAccount>
    {
       private ICacheManager _cacheManager;

       public BankAccountViewUserControl()
        {
            _cacheManager = IoCFactory.Instance.CurrentContainer.Resolve<ICacheManager>();
        }

        public SelectList BankAccountTypeSelectList
        {
            get
            {
                object result;
                result = _cacheManager.GetData(Resources.CacheKeys.BankAccountType);
                if (result == null)
                {
                    _cacheManager.StoreData(Resources.CacheKeys.BankAccountType, new SelectList(CommonController.BankAccountTypes, "TypeId", "Name"));
                    result = _cacheManager.GetData(Resources.CacheKeys.BankAccountType);
                }

                return (SelectList)result;
            }
        }

        public SelectList BankSelectList
        {
            get
            {
                object result = _cacheManager.GetData(Resources.CacheKeys.Bank);
                if (result == null)
                {
                    _cacheManager.StoreData(Resources.CacheKeys.Bank, new SelectList(CommonController.Banks, "BankId", "Name"));
                    result = _cacheManager.GetData(Resources.CacheKeys.Bank);
                }

                return (SelectList)result;
            }
        }
    }
}